package com.goods.controller.business;

import com.goods.common.model.business.Supplier;
import com.goods.common.response.ResponseBean;
import com.goods.common.vo.system.PageVO;
import com.goods.service.SupplierService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/business/supplier")
public class SupplierController {

    @Autowired
    private SupplierService supplierService;

    //物资来源分页列表展示
    @GetMapping("findSupplierList")
    public ResponseBean findSupplierList(@RequestParam(value = "pageNum") Integer pageNum,
                                         @RequestParam(value = "pageSize") Integer pageSize){
        PageVO pageVO = supplierService.findSupplierList(pageNum,pageSize);
        return ResponseBean.success(pageVO);
    }
    //添加
    @PostMapping("add")
    public ResponseBean add(@RequestBody Supplier supplier) {
        supplierService.add(supplier);
        return ResponseBean.success();
    }

    //编辑
    @GetMapping("edit/{id}")
    public ResponseBean edit(@PathVariable Long id) {
        Supplier supplier = supplierService.edit(id);
        return ResponseBean.success(supplier);
    }

    //修改
    @PutMapping("update/{id}")
    public ResponseBean update(@PathVariable Long id,@RequestBody Supplier supplier) {
        supplierService.update(id, supplier);
        return ResponseBean.success();
    }

    //删除
    @DeleteMapping("delete/{id}")
    public ResponseBean delete(@PathVariable Long id) {
        supplierService.delete(id);
        return ResponseBean.success();
    }
}
